{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "房子全新首租，通风好采光好落地窗，品牌建材豪华精装，合适中高端商住，可做工作室，网红直播间，工作室，会所，商住两用，拎包入住，内置配套齐全交通便利，离火车东站进，公交BRT直达门口地铁三号线，对面青秀万达绿地，周边配套医院超市买菜市，希望能招到有品味，爱干净，跟我一样爱护它的新主人\n",
      "============================================\n"
     ]
    }
   ],
   "source": [
    "from selenium.webdriver import Chrome\n",
    "import time\n",
    "web=Chrome()\n",
    "web.get('https://nn.58.com/zufang/pn1/')\n",
    "lists=web.find_element_by_css_selector('body > div.list-wrap > div.list-box > ul > li:nth-child(1) > div.des > h2 > a').click()\n",
    "time.sleep(1)\n",
    "web.switch_to.window(web.window_handles[-1])\n",
    "\n",
    "res=web.find_element_by_css_selector('body > div.main-wrap > div.house-detail-desc > div.main-detail-info > div.house-word-introduce.f16.c_555 > ul > li:nth-child(3) > span.a2')\n",
    "\n",
    "print(res.text)\n",
    "print('============================================')\n",
    "web.close()\n",
    "# for i in lists:\n",
    "#     i.click()\n",
    "#     time.sleep(1)\n",
    "#     web.switch_to.window(web.window_handles[-1])\n",
    "#     print('============================================')\n",
    "#     web.close()\n",
    "#     web.switch_to.window(web.window_handles[0])\n",
    "#     time.sleep(1)\n",
    "\n",
    "# res=web.find_element_by_xpath('/html/body/div[4]/div[3]/div[1]/div[2]/ul/li[2]/span[2]').text\n",
    "# print(res)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "95\n",
      "============================================\n",
      "============================================\n",
      "============================================\n",
      "============================================\n",
      "============================================\n",
      "============================================\n"
     ]
    },
    {
     "ename": "InvalidSessionIdException",
     "evalue": "Message: invalid session id\n",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mInvalidSessionIdException\u001b[0m                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-49-c200bf599f61>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      6\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlists\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      7\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mlists\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 8\u001b[1;33m     \u001b[0mweb\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mswitch_to\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mwindow\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mweb\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mwindow_handles\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      9\u001b[0m     \u001b[0mi\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mclick\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     10\u001b[0m     \u001b[0mtime\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msleep\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mD:\\anaconda3\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\u001b[0m in \u001b[0;36mwindow_handles\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m    722\u001b[0m         \"\"\"\n\u001b[0;32m    723\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mw3c\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 724\u001b[1;33m             \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mexecute\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mCommand\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mW3C_GET_WINDOW_HANDLES\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'value'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    725\u001b[0m         \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    726\u001b[0m             \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mexecute\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mCommand\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mGET_WINDOW_HANDLES\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'value'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mD:\\anaconda3\\lib\\site-packages\\selenium\\webdriver\\remote\\webdriver.py\u001b[0m in \u001b[0;36mexecute\u001b[1;34m(self, driver_command, params)\u001b[0m\n\u001b[0;32m    319\u001b[0m         \u001b[0mresponse\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcommand_executor\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mexecute\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdriver_command\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mparams\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    320\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0mresponse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 321\u001b[1;33m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0merror_handler\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcheck_response\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mresponse\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    322\u001b[0m             response['value'] = self._unwrap_value(\n\u001b[0;32m    323\u001b[0m                 response.get('value', None))\n",
      "\u001b[1;32mD:\\anaconda3\\lib\\site-packages\\selenium\\webdriver\\remote\\errorhandler.py\u001b[0m in \u001b[0;36mcheck_response\u001b[1;34m(self, response)\u001b[0m\n\u001b[0;32m    240\u001b[0m                 \u001b[0malert_text\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mvalue\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'alert'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'text'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    241\u001b[0m             \u001b[1;32mraise\u001b[0m \u001b[0mexception_class\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmessage\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mscreen\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mstacktrace\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0malert_text\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 242\u001b[1;33m         \u001b[1;32mraise\u001b[0m \u001b[0mexception_class\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmessage\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mscreen\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mstacktrace\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    243\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    244\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0m_value_or_default\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mobj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mdefault\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mInvalidSessionIdException\u001b[0m: Message: invalid session id\n"
     ]
    }
   ],
   "source": [
    "from selenium.webdriver import Chrome\n",
    "import time\n",
    "web=Chrome()\n",
    "web.get('https://nn.58.com/zufang/pn1/')\n",
    "lists=web.find_elements_by_css_selector('body > div.list-wrap > div.list-box > ul > li > div.des > h2')\n",
    "print(len(lists))\n",
    "for i in lists:\n",
    "    web.switch_to.window(web.window_handles[0])\n",
    "    i.click()\n",
    "    time.sleep(1)\n",
    "    web.switch_to.window(web.window_handles[-1])\n",
    "    #res=web.find_element_by_class_name('introduce-item')\n",
    "    #print(res.text)\n",
    "    print('============================================')\n",
    "    web.close()\n",
    "   \n",
    "    time.sleep(1)\n",
    "# time.sleep(1)\n",
    "# web.switch_to.window(web.window_handles[-1])\n",
    "\n",
    "# res=web.find_element_by_css_selector('body > div.main-wrap > div.house-detail-desc > div.main-detail-info > div.house-word-introduce.f16.c_555 > ul > li:nth-child(3) > span.a2')\n",
    "\n",
    "# print(res.text)\n",
    "# print('============================================')\n",
    "# web.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "ename": "IndentationError",
     "evalue": "unindent does not match any outer indentation level (<tokenize>, line 3)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<tokenize>\"\u001b[1;36m, line \u001b[1;32m3\u001b[0m\n\u001b[1;33m    <span class=\"a1\">房屋亮点</span>\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mIndentationError\u001b[0m\u001b[1;31m:\u001b[0m unindent does not match any outer indentation level\n"
     ]
    }
   ],
   "source": [
    "<ul class=\"introduce-item\">\n",
    "                                                <li>\n",
    "                            <span class=\"a1\">房屋亮点</span>\n",
    "                            <span class=\"a2\">\n",
    "                                <!-- 防疫服务特殊展示带hover -->\n",
    "                                                                        <em>邻地铁</em>\n",
    "                                                                            <em>配套齐全</em>\n",
    "                                                                            <em>精装修</em>\n",
    "                                                                </span>\n",
    "                        </li>\n",
    "                                                <li>\n",
    "                            <span class=\"a1\">房源描述</span>\n",
    "                            <span class=\"a2\"><p><span><span>1、装修：精装修，很干净；</span><br><br><span>2、朝向：南北通透，通风性和采光性都好；</span><br><br><span>3、户型：方方正正，布局合理，没有浪费面积；</span><br><br><span>4、交通：小区内道路宽敞，公交方便，交通十分便利。</span><br><br><span>5、室内设施：家电家具齐全，拎包入住！</span><br><br><span>7、您只需要打个电话拿着您的东西来看房就可以了，看好即可入住,朋友抓紧联系我哦！</span><br><br><span>现在市场住房紧张,请您选择正规的地产公司我们随时欢迎您*！</span></span><br><br></p><p><br><br>\n",
    "                        </p></span></li>\n",
    "                    </ul>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "94\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"c5758b5e-d3cb-438b-a8d4-5e2b3bca24b3\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"2fe8cb89-2872-42c3-a692-bba8104acc41\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"a3ba8c73-75d0-49e1-b9da-564a279ac44b\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"1f71d1be-6699-415d-90a8-8c69550533eb\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"b151f781-9209-4265-9b8c-f319e57736e7\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"a21c87eb-603a-4dfd-ab7a-3f40087ae1c0\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"ca724486-a480-40ca-9868-19d215bdbe3f\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"ea77371c-944f-474b-a020-c15c3a752ab3\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"f1d8dfc0-027d-4e58-8cb9-499fab2aa489\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"4de27ec3-38ab-4274-b7ed-450bad5ae3fb\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"6058c1c9-9d52-457e-98b6-8f43bb0857ab\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"4347c6d6-d206-4be8-a02e-547c49676032\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"f7504604-fc05-4042-883d-b051a47f59e6\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"d6bcb078-255c-41ed-a36a-39e247945640\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"83b55b42-f797-4ca5-aadd-58880e84e76d\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"e2926288-cfc1-45ae-b9c7-cfd59353e713\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"7d262fa4-0c42-4d05-8134-d06e5920ed04\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"f9263dfe-4721-42d2-99cb-93cf5fce969c\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"98ecfe33-9f38-4217-8ba8-92763aa6f6d8\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"fa8c233b-c564-4f6f-8c47-558a10a5cda0\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"5243cb42-0656-479a-b3af-a4f79cda8160\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"60df9dbd-21ba-4fdd-9d44-99be2ec5e00d\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"430aea74-c7da-42af-9c41-43c3314417a4\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"2eb76ad6-527a-40f5-92a0-d39c00b6c92a\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"b10c764f-8fed-4213-941d-b18fc2aa1a8d\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"da0deb12-2462-4473-8244-b948c08a49d5\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"b5de5539-80a5-488c-ad3b-a844fc754a40\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"75f1eb3f-3d9d-4a2a-a7ad-8bc14250515d\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"8bd43dca-b48f-4cd8-81ac-91fbc77f5b48\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"2e013d5e-7527-44cf-8221-0b0e06e86497\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"1b4d0d71-5d29-4f21-91bc-1fc2a244395b\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"26888558-befd-4977-999c-e5248c65632a\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"05b52a70-b7d9-4ffe-9ab6-454238e735a6\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"94b58553-f853-4114-995a-a483817157ec\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"8bd802af-d751-4da5-9181-6251abcb8ec3\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"38ed66af-8e97-4d3a-a503-90152d858f7a\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"7dfd71e7-7555-4980-b689-daf7f9bdec52\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"700a6372-4f66-48ad-b675-de85929d8602\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"ce382459-d10c-41a7-ae4e-416366d2a645\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"817d6982-28e5-45b4-916e-fbc2ac8f6b46\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"cda51e59-6f3d-4dac-b4f7-975b4c70ace9\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"8a676cdf-48d6-4b5b-bdf8-261d8604b378\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"d927f5d7-96f0-40ae-a36e-93bfdfbe9fda\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"092c3802-abd7-433e-ac07-05fd78960f92\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"4bbd3c6d-48a0-495c-82ac-8ff038b98915\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"90f48b7b-08ed-4f5f-ac5e-4b533f2b5acd\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"f26bdaf3-fa66-454b-822d-26caaccad1b0\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"01e8da83-4203-403b-bac7-f00c85f04cdc\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"3a0dd3a2-2903-484c-bb2b-5cea7aba0162\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"bf4d4c43-70fa-40a3-adf1-5d856f7c1d03\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"1671f6c3-c668-4a2e-8074-9dc386b93d9d\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"10e89170-5c4e-43e5-864e-e4ccdfb5e544\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"560ee130-5b1b-44fc-98b3-338122b5059e\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"dceea425-0d24-47e8-bf16-f7e6cb98c5bb\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"3340455d-0250-4ad4-abd7-20c3d80774c3\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"4887706f-a3d5-43a4-a62b-254cee5cf89e\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"8e1d2331-e732-44b8-ac94-4a86ad7aaaea\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"06e71c95-2337-49f3-8b04-e58d4bc9d842\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"1659e7fb-1022-4529-981e-5a406afd66dd\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"7ff730a8-9814-44d0-8263-c89d46fc6480\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"700a7da2-4cfe-42a1-855f-c8886381a2c5\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"62fd9c2d-3f28-4876-88d4-5be2989b7449\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"35861cd9-d51a-4a20-9f28-560ad50aa203\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"c7fa71e2-65f3-4072-b604-3ad259b58fcb\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"5383d573-09f1-4d59-9a48-4160ad1635f9\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"bcf85183-4b0d-4c0f-ac0b-8e035bd87ddd\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"72926881-4785-4483-a57d-0695dc404717\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"94adede0-d941-4e14-834c-011094a37a3e\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"0e02cd3a-89d6-42b7-a6f6-d9d4097c5d2c\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"81e6390a-0464-4b0e-bd6d-d38fcfdc4ffe\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"c7ab6436-a147-4401-b0f8-926ba6395aff\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"4f50f9a0-01e6-4213-9ddc-51f4786f1e99\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"6332b1c1-3471-45b5-af63-b543c07aa2ef\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"f6c957d5-a176-43d8-96c2-66c648678ffd\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"2b19f716-9016-4f42-b5e2-661df8591735\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"01923aa6-a85c-4242-88f5-a866aa5e800b\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"e0db607f-a9f9-4438-9cc4-ce8e576dfbdc\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"04762da6-a9ee-4529-8493-fc51caf91cf2\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"1c29955f-5dab-44cb-9ecf-c21f84326ee1\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"bb0178d4-a4f7-407d-9d37-5e2053a46591\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"aaddb3e0-cad9-4605-89fd-9076d52988c4\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"ae9835f6-2821-4815-95cf-d8440f5ca560\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"c7af76d5-6d33-4e61-9d82-90d1963bf177\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"f31029ee-3a05-4425-bc89-1bec1d1cc72c\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"5e597d46-c7e1-40c2-9a72-ee34887d6faa\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"17f048d9-ac3b-4bc8-8f43-b0f3e405c65e\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"f4a2d21a-d6c6-473b-be3c-29af3cb5d38d\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"4d06dacf-c8df-41b3-8cb3-8c0da24f03d0\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"a13a4983-ef9a-4338-a8e8-b188b181fffd\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"40aadd6c-4eef-4715-86d4-0d203953b255\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"048749ec-55c8-4c77-8930-e68870e86721\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"233065d8-2d48-47e8-99a0-926dfd23bdf9\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"ba089b1b-00cb-4a37-8696-6322eaf073d9\")>>\n",
      "============================================\n",
      "<bound method WebElement.find_elements_by_link_text of <selenium.webdriver.remote.webelement.WebElement (session=\"4c51cf4a04aec1262f81b6c639cbf391\", element=\"a2f09b44-3d0e-448e-8931-c71731931166\")>>\n",
      "============================================\n"
     ]
    }
   ],
   "source": [
    "from selenium.webdriver import Chrome\n",
    "import time\n",
    "web=Chrome()\n",
    "web.get('https://nn.58.com/zufang/pn1/')\n",
    "lists=web.find_elements_by_css_selector('body > div.list-wrap > div.list-box > ul > li > div.des > h2')\n",
    "\n",
    "#     web.switch_to.window(web.window_handles[0])\n",
    "#     i.click()\n",
    "#     time.sleep(1)\n",
    "#     web.switch_to.window(web.window_handles[-1])\n",
    "#     #res=web.find_element_by_class_name('introduce-item')\n",
    "#     #print(res.text)\n",
    "#     print('============================================')\n",
    "#     web.close()\n",
    "   \n",
    "#     time.sleep(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_execute', '_id', '_parent', '_upload', '_w3c', 'clear', 'click', 'find_element', 'find_element_by_class_name', 'find_element_by_css_selector', 'find_element_by_id', 'find_element_by_link_text', 'find_element_by_name', 'find_element_by_partial_link_text', 'find_element_by_tag_name', 'find_element_by_xpath', 'find_elements', 'find_elements_by_class_name', 'find_elements_by_css_selector', 'find_elements_by_id', 'find_elements_by_link_text', 'find_elements_by_name', 'find_elements_by_partial_link_text', 'find_elements_by_tag_name', 'find_elements_by_xpath', 'get_attribute', 'get_property', 'id', 'is_displayed', 'is_enabled', 'is_selected', 'location', 'location_once_scrolled_into_view', 'parent', 'rect', 'screenshot', 'screenshot_as_base64', 'screenshot_as_png', 'send_keys', 'size', 'submit', 'tag_name', 'text', 'value_of_css_property']"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
